<?php

$ch = curl_init();
$url = $_POST["furl"]; # "globo.com";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/*curl_setopt($ch, CURLOPT_FILETIME, true);*/

$output = curl_exec($ch);

$page_exists = curl_getinfo($ch, CURLINFO_HTTP_CODE);

echo "PAGE == ".$page_exists;

if($page_exists == 0)
 {
	echo "<BR>NAO EXISTE<BR>";
 echo "Pagina nao encontrada!";
 echo $url;
}
else
{
	echo "<BR>EXISTE<BR>";
/****************************************************************************************/
/*Teste de conexão SSL*/
$teste_ssl = curl_getinfo($ch, CURLINFO_SSL_VERIFYRESULT);

/****************************************************************************************/
/*Tempo de download da página*/
$download_timelapse = curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD);

/****************************************************************************************/
/*Tamanho da página (download)*/
$download_size = curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);

/****************************************************************************************/
/*Tempo de conclusão do 3-way Hand-Shake (TCP)*/
$twhs_tcp = curl_getinfo($ch, CURLINFO_CONNECT_TIME);

/****************************************************************************************/
/*Tempo de resposta das conexões TCP*/
$tcp_time_response = curl_getinfo($ch, CURLINFO_STARTTRANSFER_TIME);

/****************************************************************************************/
/*Tempo para a resolução do nome*/
$dns_resolution_time = curl_getinfo($ch, CURLINFO_NAMELOOKUP_TIME);

/****************************************************************************************/

?>
<!DOCTYPE html>
<head>
    <title>Estatisticas</title>
</head>
<body>

<ul>


    <li>Teste exist<br></li>
        <?php    
    print_r($page_exists );
    echo $page_exists;
               ?>
    
    <br>
    <li>Teste SSL<br></li>
        <?php    
    print_r($teste_ssl );
               ?>
    
    <br>
    <li>Tempo de download da pagina<br></li>
        <?php 
    print_r($download_timelapse);
                ?>
    <br>
    <li>Tamanho da pagina<br></li>
        <?php 
    print_r($download_size);
                ?>
    <br>
    <li>Tempo de conclusao do 3-way Hand-shake<br></li>
        <?php 
    print_r($twhs_tcp);
                ?>
    <br>
     <li>Tempo de resposta das conexoes TCP<br></li>
        <?php
    print_r($tcp_time_response);
                ?>
    <br>
    <li>Tempo para resolucao de nome DNS<br></li>
        <?php 
    print_r($dns_resolution_time);
                ?>

</ul>



</body>
</html>

<?php 

curl_close($ch);
/*Eu sinceramente não sei se isso deveria estar aqui...*/
}
?>
